package com.book.dao.impl;

import com.book.dao.UserDao;
import com.book.pojo.User;

public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User queryUserByUserName(String userName) {
        String sql="select id,username,password,email from book.t_user where username=?";
        return queryForOne(User.class,sql,userName);
    }

    @Override
    public User queryUserByUserNameAndPassword(String userName, String password) {
        String sql="select id,username,password,email from book.t_user where username=? and password=?";
        return queryForOne(User.class,sql,userName,password);
    }

    @Override
    public int saveUser(User user) {
        String sql="insert into book.t_user(username,password,email) values(?,?,?);";
        return update(sql, user.getUsername(),user.getPassword(),user.getEmail());
    }
}
